import QtQuick
import FluentUI


FluWindow {
    width: 1152
    height: 540
    visible: true
    title: qsTr("Client Desktop UI")

    closeListener: function(event){
        if(closeDestory){
            manager.destroyAllWin()
            destoryOnClose()
        }else{
            visible = false
            event.accepted = false
        }
    }

    function getSample(){
        let s = '{"res":"{\\"ori\\": {\\"file\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-user-cache/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"seg\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-seg-unet-cache/20240115152851_test115_right_center_1998_12_20240115152917_s/ori/visualization/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"grade\\": {\\"cam\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-grade/20240115152851_test115_right_center_1998_12_20240115152917_s/ori/grade/cam/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"cam_plus\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-grade/20240115152851_test115_right_center_1998_12_20240115152917_s/ori/grade/cam_plus/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"pie\\": [0.8675428032875061, 0.06645651161670685, 0.06547127664089203, 0.00037291148328222334, 0.00015648819680791348]}}, \\"enh\\": {\\"file\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-enhance-cache/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"seg\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-seg-unet-cache/20240115152851_test115_right_center_1998_12_20240115152917_s/enh/visualization/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"grade\\": {\\"cam\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-grade/20240115152851_test115_right_center_1998_12_20240115152917_s/enh/grade/cam/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"cam_plus\\": \\"http://114.55.245.149:8051/gateway/result/file?path_info=56bdf47b7294f70149a24cc5ef4e115fc2c0ee4bda796be83dd17d525c21ef5f/gateway-service-cache/mb-grade/20240115152851_test115_right_center_1998_12_20240115152917_s/enh/grade/cam_plus/20240115152851_test115_right_center_1998_12_20240115152917_s.png\\", \\"pie\\": [0.7350566387176514, 0.20122385025024414, 0.06213532015681267, 0.0013915440067648888, 0.000192699721083045]}}, \\"done\\": true}"}'
        return s
    }

    EMManager{
        id: manager
        width: parent.width
        height: parent.height
        detailSource: "qrc:/ClientDesktopUI/EMAnalysisDetail.qml"

        onListItemClick: (r1, r2)=>{
            // 查询数据库并设置给tabledata
            console.log(r1, r2)

            setPatientTableData([
                {patientName: "tacom", testId: "123", imageName: "jja.jpg", taskStatus: "0", errMsg: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                {patientName: "tacom", testId: "1223", imageName: "jj2.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "1jj.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "1224", imageName: "jj.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j3j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j8j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j74j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j9j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j6j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j5j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "j20j.jpg", taskStatus: "0", errMsg: ""},
                {patientName: "tacom", testId: "12223", imageName: "jj.jpg", taskStatus: "0", errMsg: ""}
            ])
        }

        onTableItemClick: (r1, r2, r3)=>{
            // 查询数据json并提交窗体渲染请求
            console.log(r1, r2, r3)

            // 创建渲染
            startDetailPage(r1 + "/" + r2 + "/" + r3, getSample())
        }

        Component.onCompleted: {
            setPatientListData([
                {patientName: "tacom", testId: "123"},
                {patientName: "tacom", testId: "12345"},
                {patientName: "ta", testId: "123"},
                {patientName: "t", testId: "1"},
                {patientName: "t111", testId: "1"},
                {patientName: "t2222", testId: "1"},
                {patientName: "t22", testId: "1"},
                {patientName: "t11111", testId: "1"},
                {patientName: "t____", testId: "1"}
            ])
            addPatientListItem({patientName: "hh", testId: "1"})
            addPatientListItem({patientName: "t", testId: "1222"})
        }
    }
}
